#include"SeqList.h"
void TestSeqList1()
{
	SL s;
	SeqListInit(&s);
	SeqListPushBack(&s, 1);
	SeqListPushBack(&s, 2);
	SeqListPushBack(&s, 3);
	SeqListPushBack(&s, 4);
	SeqListPushBack(&s, 5);

	SeqListPrint(&s);

	SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	//SeqListPopBack(&s);
	printf("\n");

	SeqListPushBack(&s, 4);
	SeqListPushFront(&s, 9);
	SeqListPushFront(&s, 9);
	SeqListPushFront(&s, 9);
	SeqListPushFront(&s, 9);
	SeqListPushFront(&s, 9);
	SeqListPushFront(&s, 9);
	SeqListPushFront(&s, 9);
	SeqListPushFront(&s, 9);
	SeqListPushFront(&s, 9);

	SeqListPrint(&s);
	SeqListDestory(&s);
}

void TestSeqList2()
{
	SL s;
	SeqListInit(&s);
	SeqListPushFront(&s, 1);

	SeqListPushFront(&s, 2);
	SeqListPushFront(&s, 3);
	SeqListPushFront(&s, 4);
	SeqListPushFront(&s, 5);
	SeqListPushFront(&s, 6);

	//SeqListPopFront(&s);
	//SeqListPopFront(&s);
	

	SeqListPrint(&s);
}

void TestSeqList3()
{
	SL s;
	SeqListInit(&s);
	SeqListPushBack(&s, 1);
	SeqListPushBack(&s, 2);
	SeqListPushBack(&s, 3);
	SeqListPushBack(&s, 4);
	// SeqListInsert(&s, 2, 30);
	//SeqListPushBack(&s, 8);
	//SeqListPushFront(&s, 12);
	// SeqListPopBack(&s);

	SeqListErase(&s, SeqListFind(&s, 3));
	SeqListPrint(&s);
}


void Menu()
{
	printf("***************************************\n");
	printf("1、增加数据\n");
	printf("2、删除数据\n");
	printf("3、查看数据\n");
	printf("4、修改数据\n");
	printf("0 ： 退出程序\n");
	printf("***************************************\n");
}

void Test_Menu()
{
	SL test;
	SeqListInit(&test);
	int input = 0;
	SLDataType x = 0;
	do
	{
		Menu();
		printf("input>");
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			printf("请输入要增加的数据：");
			scanf("%d", &x);
			while (x != -1)
			{
				SeqListPushBack(&test, x);
				scanf("%d", &x);
			}
			
			break;
		case 2:
			SeqListPopBack(&test);
			break;
		case 3:
			SeqListPrint(&test);
			printf("\n");
			break;
		case 4:
			printf("请输入要修改的值 : ");
			scanf("%d", &x);
			
			int temp = 0;
			int index = SeqListFind(&test, x);
			if (index == -1)
			{
				printf("没有该数据\n");
				printf("更改失败\n");
			}
			else
			{
				printf("跟改为：");
				scanf("%d", &temp);
				SeqListErase(&test, index);
				SeqListInsert(&test, index,temp);
				printf("更改成功\n");
			}
			break;
		case 0:
			SeqListDestory(&test);
			printf("退出程序\n");
			break;
		default :
			printf("请输入正确值!!!\n");
			break;
		}
	} while (input);
}
int main()
{
	// TestSeqList1();
	// TestSeqList2();
	// TestSeqList3();
	Test_Menu();
	return 0;
}

